package com.pengshun.modules.api.order.service.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonView;
import com.pengshun.modules.api.coal.validator.*;
import com.pengshun.modules.common.ReslutView;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;

@Data
public class MerchantOrderDto {

    @NotNull(message = "订单id不能为空", groups = {Second.class, Third.class, Fifth.class})
    @JsonView(ReslutView.aView.class)
    private Long orderId;

    @ApiModelProperty(value = "订单号")
    @JsonView(ReslutView.aView.class)
    private String orderNo;

    @ApiModelProperty(value = "煤炭id")
    @JsonView(ReslutView.aView.class)
    private Long coalId;

    @ApiModelProperty(value = "买方用户id")
    private Long buyUserId;
    private Long mineMouthId;
    //取消拒绝原因
    @JsonView(ReslutView.aView.class)
    private String cause;

    private String abbreviationAddress;

    @ApiModelProperty(value = "卖方用户id")
    private Long sellUserId;

    @ApiModelProperty(value = "卖方商户id")
    @JsonView(ReslutView.aView.class)
    private Long merchantId;

    @ApiModelProperty(value = "商户煤炭id", required = true)
    @NotNull(message = "煤炭id不能为空", groups = {First.class})
    private Long merchantCoalId;

    @ApiModelProperty(value = "煤炭竞拍价")
    private BigDecimal coalPrice;

    @ApiModelProperty(value = "销售价格")
    @JsonView(ReslutView.aView.class)
    private BigDecimal sellPrice;

    @ApiModelProperty(value = "交易数量", required = true)
    @NotNull(message = "数量不能为空", groups = {First.class})
    @JsonView(ReslutView.aView.class)
    private BigDecimal number;

    @ApiModelProperty(value = "价格单位", required = true)
//    @NotNull(message = "价格单位不能为空", groups = {First.class})
    @JsonView(ReslutView.aView.class)
    private String priceUnit;

    @ApiModelProperty(value = "运输方式(1委托经销商指定运输公司，2自运,3,自己指定运输公司，4自己指定车主，5自己指定司机)")
    @NotNull(message = "运输方式不能为空", groups = {First.class})
    @JsonView(ReslutView.aView.class)
    private Integer transportWay;

    @ApiModelProperty(value = "结算方式(1全款，2按车付费)")
    private Integer cleanWay;

    @ApiModelProperty(value = "总价格(煤炭总价)")
    @NotNull(message = "总价格不能为空", groups = {First.class})
    @JsonView(ReslutView.aView.class)
    private BigDecimal totalPrice;

    @ApiModelProperty(value = "运费(元/每吨)")
    @JsonView(ReslutView.aView.class)
    private BigDecimal freight;

    @ApiModelProperty(value = "总运费")
    @JsonView(ReslutView.aView.class)
    private BigDecimal totalFreight;

    @ApiModelProperty(value = "已付总运费")
    private BigDecimal payTotalFreight;

    @ApiModelProperty(value = "已支付煤款")
    private BigDecimal payTotalPrice;

    @ApiModelProperty(value = "支付方式(1余额，2微信，3支付宝，4银行卡，5余额+微信，6余额+支付宝，7余额+银行卡)")
    @JsonView(ReslutView.aView.class)
    private Integer payWay;

    @ApiModelProperty(value = "交易备注")
    @JsonView(ReslutView.aView.class)
    private String remark;

    @ApiModelProperty(value = "订单状态(1已下单,2用户取消,3商户确认,4商户拒绝，5关闭（24小时），6已支付，7已完成)")
    @NotNull(message = "状态不能为空", groups = {Third.class})
    @JsonView(ReslutView.aView.class)
    private Integer orderStatus;


    @ApiModelProperty(value = "创建时间")
    @JsonView(ReslutView.aView.class)
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @ApiModelProperty(value = "收货人")
    @JsonView(ReslutView.aView.class)
    private String name;

    @ApiModelProperty(value = "收货人电话")
    @JsonView(ReslutView.aView.class)
    private String phone;

    @ApiModelProperty(value = "省份code")
    private Integer spId;

    @ApiModelProperty(value = "城市code")
    private Integer scId;

    @ApiModelProperty(value = "区县code")
    private Integer sdId;

    @ApiModelProperty(value = "详细地址")
    @JsonView(ReslutView.aView.class)
    private String address;

    @ApiModelProperty(value = "纬度")
    private Double lngX;

    @ApiModelProperty(value = "经度")
    private Double latY;
    @JsonView(ReslutView.aView.class)
    private String province;
    @JsonView(ReslutView.aView.class)
    private String city;
    @JsonView(ReslutView.aView.class)
    private String district;

    @JsonView(ReslutView.aView.class)
    private Long userAddressId;
    @NotNull(message = "当前页不能为空", groups = {Fourth.class})
    private Integer page;
    @NotNull(message = "条数不能为空", groups = {Fourth.class})
    private Integer size;

    private Integer moeny;
    /**
     * 操作人员id
     */
    private Long userId;

    /**
     * 1煤款+运费、2煤款、3运费
     */
    private Integer type;

    private Integer isDefault;

    private String userName;
    @JsonView(ReslutView.aView.class)
    private String merchantName;
    @JsonView(ReslutView.aView.class)
    private String mineMouthName;
    @JsonView(ReslutView.aView.class)
    private String coalName;
    @JsonView(ReslutView.aView.class)
    private Integer businessType;
    @JsonView(ReslutView.aView.class)
    private Integer payType;
    @JsonView(ReslutView.aView.class)
    private String coalPic;
    @JsonView(ReslutView.aView.class)
    private String coalCalorific;
    @JsonView(ReslutView.aView.class)
    private String allSulphur;
    @JsonView(ReslutView.aView.class)
    private String linkmanPhone;
    @JsonView(ReslutView.aView.class)
    private String sulphurContent;
    private Integer billType;
    /**
     *  是否评价0否1是
      */
    @JsonView(ReslutView.aView.class)
    private Integer isEstimate;
    /**
     * // 确定时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonView(ReslutView.aView.class)
    private Date sureTime;

    /**
     *    //支付时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonView(ReslutView.aView.class)
    private Date payTime;

    /**
     * //取消时间
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonView(ReslutView.aView.class)
    private Date cancleTime;
    //完成时间
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonView(ReslutView.aView.class)
    private Date overTime;
    //拒绝时间
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonView(ReslutView.aView.class)
    private Date backTime;

    private String payPass;



//    List<CategoryResult> categorys;

//    public String getWholeWater() {
//        String water = null;
//        if (this.categorys != null && this.categorys.size() > 0) {
//            for (CategoryResult to : categorys) {
//                if (to.getName().equals(CoalInfoEnum.WHOLE_WATER.getKey())) {
//                    water = to.getValue() + UnitEnum.PERCENT.getKey();
//                }
//            }
//        }
//        water = water == null ? "0%" : water;
//        return water;
//    }
//
//    public String getSulphurContent() {
//        String sulphur = null;
//        if (this.categorys != null && this.categorys.size() > 0) {
//            for (CategoryResult to : categorys) {
//                if (to.getName().equals(CoalInfoEnum.SULPHUR_CONTENT.getKey())) {
//                    sulphur = to.getValue() + UnitEnum.PERCENT.getKey();
//                }
//            }
//        }
//        sulphur = sulphur == null ? "0%" : sulphur;
//        return sulphur;
//    }


}
